package org.csc.sss.datacore.primary.repository;

import org.csc.sss.datacore.primary.model.SysUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Date;

public interface SysUserRepository extends JpaRepository<SysUser, String>, JpaSpecificationExecutor<SysUser>{
	
	SysUser findBynickname(String nickname);

	/**
	 * 记录登录用户的登录时间
	 * @param lastLoginTime
	 * @param id
	 * @return
	 */
	@Modifying
	@Query(value = "update SysUser u set u.lastLoginTime = :lastLoginTime where u.id = :id")
	int updateSysUser(@Param(value = "lastLoginTime") Date lastLoginTime, @Param(value = "id") String id);

}
